<%@ page import="cn.gudian.cms.Admin.AdminUser" %>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="layout" content="main"/>
  <title><g:message code="adminUser.edit" default="Edit AdminUser"/></title>
</head>
<body onload="">

<div class="nav">
  <span class="menuButton"><a class="home" href="${createLinkTo(dir: '')}"><g:message code="home" default="Home"/></a></span>
  <span class="menuButton"><g:link class="list" action="list"><g:message code="adminUser.list" default="AdminUser List"/></g:link></span>
  <gd:isPermit roles="SYSTEM_ADMIN"><span class="menuButton"><g:link class="create" action="create"><g:message code="adminUser.new" default="New AdminUser"/></g:link></span></gd:isPermit>
</div>
<div class="body">
  <h1><g:message code="adminUser.edit" default="Edit AdminUser"/></h1>
  <g:if test="${flash.message}">
    <div class="message"><g:message code="${flash.message}" args="${flash.args}" default="${flash.defaultMessage}"/></div>
  </g:if>
  <g:hasErrors bean="${adminUserInstance}">
    <div class="errors">
      <g:renderErrors bean="${adminUserInstance}" as="list"/>
    </div>
  </g:hasErrors>
  <g:form method="post" onSubmit="return copydata()">
    <g:hiddenField name="id" value="${adminUserInstance?.id}"/>
    <g:hiddenField name="version" value="${adminUserInstance?.version}"/>
    <div class="dialog">
      <table>
        <tbody>
           <tr class="prop">
            <td valign="top" class="name">
              <label for="adminRole"><g:message code="adminUser.adminRole" default="Admin Role"/>:</label>
            </td>
            <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'adminRole', 'errors')}">
              <g:select name="adminRole.id" from="${cn.gudian.cms.Admin.AdminRole.list()}" optionKey="id" value="${adminUserInstance?.adminRole?.id}"/>

            </td>
          </tr>
        <tr class="prop">
          <td valign="top" class="name">
            <label for="userName"><g:message code="adminUser.userName" default="User Name"/>:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'userName', 'errors')}">
            <gd:isPermit roles="SYSTEM_ADMIN"><input name="userName" maxlength="15" value="</gd:isPermit>
${fieldValue(bean: adminUserInstance, field: 'userName')}
<gd:isPermit roles="SYSTEM_ADMIN">"/></gd:isPermit>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="password"><g:message code="adminUser.password" default="Password"/>:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'password', 'errors')}">
            <g:link action="changepass" id="${adminUserInstance.id}">修改密码</g:link>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="realName"><g:message code="adminUser.realName" default="Real Name"/>:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'realName', 'errors')}">
            <g:textField name="realName" value="${fieldValue(bean: adminUserInstance, field: 'realName')}"/>

          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="mobile"><g:message code="adminUser.mobile" default="Mobile"/>:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'mobile', 'errors')}">
            <g:textField name="mobile" value="${fieldValue(bean: adminUserInstance, field: 'mobile')}"/>

          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="email"><g:message code="adminUser.email" default="Email"/>:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'email', 'errors')}">
            <g:textField name="email" value="${fieldValue(bean: adminUserInstance, field: 'email')}"/>

          </td>
        </tr>
        <gd:isPermit roles="SYSTEM_ADMIN">
          <tr class="prop">
            <td valign="top" class="name">
             可管理的栏目:
            </td>
            <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'arcTypeIDs', 'errors')}">
              <input name="arcTypeIDs" id="arcTypeIDs" type="hidden" value="${fieldValue(bean: adminUserInstance, field: 'arcTypeIDs')}"/>
              <gd:arcTypeMultipleSelect nbsp="1" size="11" id="arcType"></gd:arcTypeMultipleSelect>
            </td>
          </tr>


        </gd:isPermit>
        <tr class="prop">
          <td valign="top" class="name">
            <label for="loginNum"><g:message code="adminUser.loginNum" default="Login Num"/>:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'loginNum', 'errors')}">
            ${fieldValue(bean: adminUserInstance, field: 'loginNum')}

          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="lastLoginTime"><g:message code="adminUser.lastLoginTime" default="Last Login Time"/>:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'lastLoginTime', 'errors')}">
            ${adminUserInstance?.lastLoginTime}

          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="lastLoginIP"><g:message code="adminUser.lastLoginIP" default="Last Login IP"/>:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: adminUserInstance, field: 'lastLoginIP', 'errors')}">
            ${fieldValue(bean: adminUserInstance, field: 'lastLoginIP')}
          </td>
        </tr>

        </tbody>
      </table>
    </div>
    <div class="buttons">
      <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'update', 'default': 'Update')}"/></span>
      <gd:isPermit roles="SYSTEM_ADMIN"><span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'delete', 'default': 'Delete')}" onclick="return confirm('${message(code: 'delete.confirm', 'default': 'Are you sure?')}');"/></span></gd:isPermit>
    </div>
  </g:form>
</div>
<script>
  document.onLoad = multiple();
  function multiple() {
    var hide = document.getElementById("arcTypeIDs");
    var arrstr = hide.value;
    var arr = arrstr.split(',');
    var list = document.getElementById("arcType");

    for (var i = 0; i < list.options.length; i++) {
      for (var j = 0; j < arr.length; j++) {
        if (list.options[i].value == arr[j].toString())
        {
          list.options[i].selected = true;
        }
      }
    }
  }
  function copydata() {
    var hide = document.getElementById("arcTypeIDs");
    var arrstr = hide.value;
    var arr = arrstr.split(',');
    var list = document.getElementById("arcType");
    hide.value = "";
    for (var i = 0; i < list.options.length; i++) {
      if (list.options[i].selected == true)
      {
        hide.value += list.options[i].value + ",";
      }
    }
    return true;
  }
</script>
</body>
</html>
